/**
 * 计算时间差值
 * @param startTime 开始时间，形如hh:mm
 * @param endTime  结束时间，形如hh:mm
 */
export const calMinutesBetweenTimes = (startTime: string, endTime: string) => {
  // Split start and end times into hours and minutes
  const [startHour, startMinute] = startTime.split(':').map(Number);
  const [endHour, endMinute] = endTime.split(':').map(Number);

  // Create Date objects for start and end times
  const startDate = new Date();
  startDate.setHours(startHour);
  startDate.setMinutes(startMinute);

  const endDate = new Date();
  endDate.setHours(endHour);
  endDate.setMinutes(endMinute);

  // Calculate difference in minutes between start and end times
  const diffMs = endDate.getTime() - startDate.getTime();
  const diffMins = Math.round(diffMs / 60000);

  return diffMins;
};

export function getCurrentTime() {
  const currentDate = new Date();
  let hours = currentDate.getHours();
  let minutes = currentDate.getMinutes();

  // 添加前导零
  if (hours < 10) {
    hours = `0${hours}`;
  }
  if (minutes < 10) {
    minutes = `0${minutes}`;
  }

  const currentTime = `${hours}:${minutes}`;
  return currentTime;
}
